<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    var arr=new Array();
for(var i=0;i<4;i++){
    arr[i]=function(){

        console.log(i);
    }
}
    arr[0]();
    arr[1]();
    arr[2]();
    arr[3]();
</script>
</body>
</html>